import { View } from "../../../mvc/core/View";
import { LayerManager } from "../../manager/LayerManager";
import { EffectManager } from "../../manager/EffectManager";
import { TaskInfo } from "../../model/TaskInfo";
import { ObjCreate } from "../common/ObjCreate";
import { ResFileConst } from "../../resource/ResFileConst";
import { Alert } from "../../../../com/mui/controls/Alert";
import { Language } from "../../../../extend/language/Language";
import { AIManager } from "../../scene/ai/AIManager";
import { AIType } from "../../scene/ai/AIType";
import { GLoadedButton } from "../../../../com/mui/controls/GLoadedButton";
type int = number;
//class MagicWeaponGuideTaskIcon
    
    export  class MagicWeaponGuideTaskIcon extends View
    {
        constructor()
        {
            super();
            this.layer = LayerManager.rightTopUILayer;
            this.createChildren();
            this.addListeners();
            return;
        }

        public showEffect(arg1: Boolean): void
        {
            var loc1=null;
            var loc2=null;
            if (arg1) 
            {
                loc1 = new Object /* flash.filters.GlowFilter */(268435302, 1, 6, 6, 4);
                loc2 = [loc1];
                EffectManager.glowFilterReg(this._btn, loc2, 0.8, 10, 5, 0);
            }
            else 
            {
                EffectManager.glowFilterUnReg(this._btn);
            }
            return;
        }

        public showMe(arg1: int=0, arg2: int=0, arg3: TaskInfo=null): void
        {
            this._taskInfo = arg3;
            super.show(arg1, arg2);
            this.showEffect(true);
            return;
        }

        public clean(): void
        {
            this._taskInfo = null;
            this.showEffect(false);
            return;
        }

        /* internal  */createChildren(): void
        {
            this._btn = ObjCreate.createGLoadedButton(ResFileConst.MagicWeaponGuideTaskIcon, 0, 0, 60, 50, this);
            this.showEffect(true);
            return;
        }

        /* internal  */addListeners(): void
        {
            this._btn.addEventListener(flash.events.MouseEvent.CLICK, this.clickAchievementHandler);
            return;
        }

        protected clickAchievementHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Alert.buttonWidth = 65;
            Alert.okLabel = Language.getString(60064);
            Alert.calcelLabel = Language.getString(70433);
            Alert.showCloseBtn = true;
            Alert.show(Language.getString(80347), null, Alert.OK | Alert.CANCEL | Alert.CLOSE, null, this.closeHandler);
            return;
        }

        /* internal  */closeHandler(arg1: int): void
        {
            if (this._taskInfo == null) 
            {
                return;
            }
            var loc1=this._taskInfo.getTargetByIndex(0);
            if (loc1 == null) 
            {
                return;
            }
            if (arg1 != Alert.OK) 
            {
                if (arg1 == Alert.CANCEL) 
                {
                    AIManager.onAIControl(loc1, AIType.AI_Convey);
                }
            }
            else 
            {
                AIManager.onAutoPathAIControl(loc1);
            }
            return;
        }

        /* internal */ /* var */_btn: GLoadedButton;

        /* internal */ /* var */_taskInfo: TaskInfo;
    }
